﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StructureMap.Configuration.DSL;
using BonsaiScrum.Core.Persistance;
using NHibernate;
using BonsaiScrum.Bus;
using BonsaiScrum.Data.Reporting;

namespace BonsaiScrum.Data
{
    public class NHibernateRegistry : Registry
    {
        public NHibernateRegistry()
        {
            For<IDomainRepository>()
                .Singleton()
                .Use<NHibernateDomainRepository>();

            For<ITransactional>()
                .Use(context => context.GetInstance<IDomainRepository>());

            For<ISessionSource>()
                .Singleton()
                .Use<NHibernateSessionSource>();

            For<ISession>()
                .Use(context => context.GetInstance<ISessionSource>().CreateSession());

            For<IProjectReportingRepository>()
                .Use<NHibernateProjectReportingRepository>();

            For<ISprintReportingRepository>()
                .Use<NHibernateSprintReportingRepository>();

            For<IUserReportingRepository>()
                .Use<NHibernateUserRepository>();
        }
    }
}
